﻿<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>在途</title>
    <link href="Scripts/bootstrap/css/bootstrap.css" rel="stylesheet" type="text/css" />
    <link href="Scripts/bootstrap/css/font-awesome.css" rel="stylesheet">
    <link href="Style/skin/css/style.css" rel="stylesheet" type="text/css" />
    <link href="Style/skin/css/animate.css" rel="stylesheet" type="text/css" />
    <link href="Style/skin/font/iconfont.css" rel="stylesheet" type="text/css" />
   

</head>
<body class="gray-bg">
    <div class="wrapper wrapper-content animated fadeInRight">
        <div class="ibox-content">
            <table class="table  table-striped">
                <thead id="threadDiv"></thead>
                <tbody id="Table1"></tbody>
            </table>
            <div class="row">
                <div class="col-sm-12">
                    <span id="Table2"></span>
                </div>
            </div>
        </div>
    </div>
    <script language="JavaScript" src="./Comm/JScript.js" type="text/javascript"></script>
    <script type="text/javascript" src="./Scripts/bootstrap/js/jquery.min.js"></script>
    <script type="text/javascript" src="./Scripts/bootstrap/js/bootstrap.min.js"></script>
    <script src="./Scripts/QueryString.js" type="text/javascript"></script>
    <script src="./Scripts/config.js" type="text/javascript"></script>
    <script src="Comm/Gener.js" type="text/javascript"></script>

    <script src="Scripts/layui/layui/lay/modules/layer.js" type="text/javascript"></script>
    <script src="../DataUser/JSLibData/CommonShowConfig.js"></script>
    <!-- 处理多语言 -->
    <script src="Data/lang/load.js" type="text/javascript"></script>
    <script language="javascript" type="text/javascript">

        var RunModel = { "Ordinary": 0, "HL": 1, "FL": 2, "FHL": 3, "SubThread": 4 };
        var isContainFuture = GetQueryString("IsContainFuture");
        if (isContainFuture == null || isContainFuture == undefined || isContainFuture == "")
            isContainFuture = "0";
        var Hide_HastenWork = getConfigByKey("Hide_HastenWork", false); //是否隐藏该条信息, CommonShowConfig.js中定义

        //页面启动函数.
        $(function () {
            var _html = '';
            _html = `<tr>
            <th width="40">
                #
                </th>
                <th width="350"> ${window.lang.biaoti}  </th>
                <!--  <th>流程</th>-->
                <th width="120">
                    ${window.lang.fqr}
                </th>
                <th width="200">
                    ${window.lang.fqbm}
                </th>
                <!--<th>申请时间</th>-->
                <th width="180">
                     ${window.lang.dqjd}
                </th>
                <th width="200">
                   ${window.lang.sdrq}
                </th>
                
                <th width="120">
                    ${window.lang.dqclr}
                </th>
                <!--<th width="120">
                    操作
                </th>-->
            </tr>`;
            $("#threadDiv").html(_html);
           InitPage();
        });

        function GroupBarClick(groupName) {

            var alt = document.getElementById('Img' + groupName).alert;
            var sta = 'block';
            if (alt == 'Max') {
                sta = 'block';
                alt = 'Min';
                classname = 'fa fa-minus-square';
            } else {
                sta = 'none';
                alt = 'Max';
                classname = 'fa  fa-plus-square';
            }

            document.getElementById('Img' + groupName).className = classname;
            document.getElementById('Img' + groupName).alert = alt;

            var i = 0;
            for (i = 0; i <= 600; i++) {

                var row = document.getElementById(groupName + i);

                if (row == null || row == undefined || row.style == null)
                    continue;

                if (sta == 'block') {
                    row.style.display = '';
                } else {
                    row.style.display = sta;
                }
            }
        }

        /* ESC Key Down */
        function Esc() {
            if (event.keyCode == 27)
                window.close();
            return true;
        }

        /* 打开表单. */
        function OpenFrm(workid, nodeID, flowNo, fid, title) {
            JumpFlowPage("MyView", title, workid, flowNo, nodeID, fid);
            return;
        }


        /**
         *  为什么写到这里？ Gener.js 是一个与其他任何业务模块无关的js文件.
         * 执行跳转到MyFlow/MyView页面的判断方法:
         * @param {any} title
         * @param {any} workid
         * @param {any} fk_flow
         * @param {any} fk_node
         * @param {any} fid
         * @param {any} pworkid
         */
        function JumpFlowPage(pageType, title, workid, fk_flow, fk_node, fid, pworkid, isread, paras) {
            var handler = new HttpHandler("BP.WF.HttpHandler.WF_MyFlow");
            if (pageType == "MyView")
                handler = new HttpHandler("BP.WF.HttpHandler.WF_MyView");

            if (workid != null && workid != undefined)
                handler.AddPara("WorkID", workid);
            handler.AddPara("FK_Flow", fk_flow);
            if (fk_node != null && fk_node != undefined)
                handler.AddPara("FK_Node", fk_node);
            if (fid != null && fid != undefined)
                handler.AddPara("FID", fid);
            if (pworkid != null && pworkid != undefined)
                handler.AddPara("PWorkID", pworkid);
           
                handler.AddPara("IsReadonly", 1);
            if (paras != null && paras != undefined)
                handler.AddPara("Paras", paras);


            var data = "";
            if (pageType == "MyView")
                data = handler.DoMethodReturnString("MyView_Init");
            else
                data = handler.DoMethodReturnString("MyFlow_Init");

            if (data.indexOf('err@') == 0) {
                alert(data);
                return;
            }

            if (data.indexOf('url@') == 0) {

                data = data.replace('url@', ''); //如果返回url，就直接转向.
                data = data.replace('?DoType=HttpHandler', '?');
                data = data.replace('&DoType=HttpHandler', '');
                data = data.replace('&DoMethod=MyFlow_Init', '');
                data = data.replace('&HttpHandlerName=BP.WF.HttpHandler.WF_MyFlow', '');
                data = data.replace('?&', '?');
                var url = data;
                url = url.replace('/WF//WF/', '/WF/');
                if (url.indexOf("http") == -1) {
                    if (url.indexOf('/WF/') == -1)
                        url = '/WF/' + url;
                    url = basePath + url;
                }
                try {
                    if (window.top.vm != undefined) {
                        window.top.vm.openTab(title, url);
                        return;
                    }
                    window.open(url); //打开流程.
                } catch (e) {
                    data = data.replace('/WF//WF/', '/WF/');
                    window.open(data); //打开流程.
                    return;
                }
            }
        }

        //初始化数据.
        function InitPage() {

            //获取参数，FlowNos，为空时显示所有的待办，否则显示参数中的流程
            var flowNos = GetQueryString("FlowNos");

            //随机串.
            var timeKey = Math.random();

            var handler = new HttpHandler("BP.WF.HttpHandler.WF");
            handler.AddPara("IsContainFuture", isContainFuture);
            handler.AddPara("FK_Flow", GetQueryString("FK_Flow"));
            var data = handler.DoMethodReturnString("Runing_Init");

            if (data.indexOf('err@') == 0) {
                alert(data);
            }

            data = JSON.parse(data);

            //生成分组的字符串.
            var str = "@";
            for (var i = 0; i < data.length; i++) {
                if (str.indexOf('@' + data[i].FlowName + "@") == -1) {
                    if (flowNos == null || (flowNos != null && flowNos.indexOf(data[i].FK_Flow) != -1))
                        str += data[i].FlowName + "@";
                }

            }
            var strs = str.split("@"); //生成数组.

            var num = 0;
            var is1 = false;
            var listbox = '';

            //循环数组.
            for (var idx = 0; idx < strs.length; idx++) {

                var groupName = strs[idx];

                if (groupName == "" || groupName == null)
                    continue;

                listbox += "<tr  onclick=\"GroupBarClick('" + groupName + "')\" > <th colspan=8 class='table-title'> <i class='fa fa-minus-square' alert='Min'  id='Img" + groupName + "'></i><span>" + groupName + "</span></th> </tr>";


                //增加处理.
                for (var i = 0; i < data.length; i++) {
                    var work = data[i];
                    if (work.FlowName != groupName)
                        continue;

                    num++;

                    if (is1 == true) {
                        listbox += "<tr  id='" + groupName + num + "' >";
                        is1 = false;
                    } else {
                        listbox += "<tr  id='" + groupName + num + "' >";
                        is1 = true;
                    }

                    listbox += "<td>" + num + "</td>";


                    var currNodeId = work.CurrNode;
                    var currNodeName = work.CurrNodeName;
                    if (currNodeName == "")
                        currNodeName = work.NodeName


                    listbox += "<td><a href=\"javascript:OpenFrm('" + work.WorkID + "','" + work.CurrNode + "','" + work.FK_Flow + "','" + work.FID + "','" + work.FlowName + "')\" >" + work.Title + "</a></td>";
                    //  newRow += "<td>" + work.FlowName + "</td>";
                    listbox += "<td>" + work.StarterName + "</td>";
                    listbox += "<td>" + work.DeptName + "</td>";
                    //  newRow += "<td>" + work.FlowStartRDT + "</td>";
                    listbox += "<td>" + work.NodeName + "</td>";
                    listbox += "<td>" + work.RDT + "</td>";

                    var todoEmps = work.TodoEmps;
                    var emp = "";
                    var todoEmp = todoEmps.split(";");
                    for (j = 0; j < todoEmp.length; j++) {
                        if (todoEmp[j] == '' || todoEmp[j] == null || todoEmp[j] == undefined)
                            continue;
                        if (todoEmp[j].indexOf(',') != -1) {
                            var aa = todoEmp[j].split(",")[1] + "、";
                            emp += aa;

                        } else {
                            emp += todoEmp[j] + "、";
                        }
                    }
                    emp = emp.substring(0, emp.lastIndexOf("、"));
                    listbox += "<td>" + emp + "</td>";

                    //listbox += "<td>";
                    ////listbox += "[<a href=\"javascript:WinOpenIt('WFRpt.htm?FK_Flow=" + work.FK_Flow + "&FID=0&WorkID=" + work.WorkID + "&FK_Node=" + nodeID + "&FID=" + work.FID + "&IsRead=0&T=" + timeKey + "');\" >轨迹</a>][<a href=\"javascript:UnSend('" + work.FK_Flow + "','" + work.WorkID + "','" + work.FID + "','"+currNodeId+"')\">撤销</a>]";
                    //listbox += "<a href=\"javascript:WinOpenIt('" + work.WorkID + "','" + work.FK_Node + "','" + work.FK_Flow + "','" + work.FID + "','" + currNodeId + "');\" >轨迹</a>";
                    //if (work.RunType == 0 || work.RunType == undefined) {
                    //    listbox += "&nbsp;<a href =\"javascript:UnSend('" + work.FK_Flow + "','" + work.WorkID + "','" + work.FID + "','" + currNodeId + "')\">撤销发送</a>";
                    //    listbox += "&nbsp;<a href =\"javascript:UnCC('" + work.FK_Flow + "','" + work.WorkID + "','" + work.FID + "','" + currNodeId + "')\">撤销抄送</a>";
                    //    //判断是否隐藏
                    //    if (Hide_HastenWork == true) {
                    //        listbox += "&nbsp;<a href=\"javascript:Press('" + work.FK_Flow + "','" + work.WorkID + "','" + work.FID + "')\">催办</a>";
                    //    }
                    //}
                    //listbox += "</td>";

                    listbox += "</tr>";

                }
            }

            $('#Table1').html(listbox);
            $("#Table2").html(window.lang.heji + ": " + data.length +" "+ window.lang.records);
        }
    </script>
</body>
</html>
